/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hu.demo.restwsdemo2;

import java.io.InputStream;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 *
 * @author tozo
 */
@Path("/helloworld2")
@Stateless
public class HelloWorldResource {

    private StatusInfoBean sib = new StatusInfoBean();
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    public void write(){
        System.out.print("write");
    }
    
    @GET
    @Path("/get")
    //@Produces("application/xml")
    @Produces(MediaType.APPLICATION_JSON)
    public StatusInfoBean getStatus() {
        sib.getV().add("Element1");
        sib.getV().add("Element2");
        //System.out.print(id);
        return sib;
    }
    //teszt:http://localhost:8080/RestWSDemo2/
    //a post url-t meg kell nézni a jsp-ben.
    @Path("/post")
    @Produces(MediaType.TEXT_PLAIN)
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @POST
     public void demo(@FormParam("_name") String name){
        System.out.print(name);
        //return null;
        //String result = bean.toString();
        //return bean;
    }
  /*  @GET
    // The Java method will produce content identified by the MIME Media
    // type "text/plain"
    @Produces("text/plain")
    public String getClichedMessage() {
        // Return some cliched textual content
      //  demo.write();
        return "Hello World";
    }     
*/
}
